#include "../include/mytest.h"
#include "../include/mystring.h"

const int test_time = 10;

int main(void)
{
    RAND_INIT
    char _buf1[64];
    char buf1[64];
    char buf2[64];
    for(int i = 0; i < test_time; i++)
    {
        int n = RAND(0,30);
        generate_one_string(buf2);
        
        _strcpy(_buf1, buf2);
        strcpy(buf1, buf2);
        if(strcmp(buf1, _buf1) != 0)
        {// zzk: code here is really bad
            fprintf(stderr, "[strcpy] buf1 = %s while _buf1 = %s", buf1, _buf1);
            fprintf(stderr, T_R("FAIL!\n"));
            assert(0);
        }

        _strncpy(_buf1, buf2, n);
        strncpy(buf1, buf2, n);
        if(strcmp(buf1, _buf1) != 0)
        {
            fprintf(stderr, "[strncpy] buf1 = %s while _buf1 = %s", buf1, _buf1);
            fprintf(stderr, T_R("FAIL!\n"));
            assert(0);
        }
    }

    printf(T_G("ALL PASS!\n"));
    return 0;
}